from django.contrib import admin
from my_example.models import *
# Register your models here.

@admin.register(jineng)
class JiNengAdmin(admin.ModelAdmin):
    search_fields = ("name",)
    list_filter = ("zhiye",)
    list_display = ("name","zhiye")

@admin.register(renwu)
class RenWuAdmin(admin.ModelAdmin):
    list_display=("name","zhiye",)


@admin.register(jineng_attrs)
class jineng_attrs_Admin(admin.ModelAdmin):
    search_fields = ("name",)


@admin.register(jineng_key_value)
class jineng_key_value_Admin(admin.ModelAdmin):
    search_fields = ("jineng__name","attr_name__name")
    list_display=("jineng","attr_name","attr_value")
    raw_id_fields = ("attr_name","jineng")
    # filter_horizontal=("attr_name","jineng")



@admin.register(zhuangbei)
class zhuangbei_Admin(admin.ModelAdmin):
    search_fields = ("name",)

@admin.register(chenghao)
class chenghao_Admin(admin.ModelAdmin):
    search_fields = ("name",)

@admin.register(zhuangbei_key_value)
class zhuangbei_key_value_Admin(admin.ModelAdmin):
    raw_id_fields=("zhuangbei","attr_name" )
    list_display = ("zhuangbei", "attr_name", "attr_value")
    search_fields = ("zhuangbei__name",)

@admin.register(chenghao_key_value)
class chenghao_key_value_Admin(admin.ModelAdmin):
    raw_id_fields=("chenghao","attr_name" )
    list_display = ("chenghao", "attr_name", "attr_value")
    search_fields = ("chenghao__name",)


@admin.register(renwu_jieng)
class renwu_jieng_Admin(admin.ModelAdmin):
    raw_id_fields = ("jineng",)
    list_display = ("renwu","jineng")
    search_fields = ("renwu__name",)

@admin.register(renwu_zhuangbei)
class renwu_zhuangbei_Admin(admin.ModelAdmin):
    List_display_links = ()  # 禁用编辑链接
    raw_id_fields = ("zhuangbei",)
    list_display = ("renwu", "zhuangbei")
    search_fields = ("renwu__name",)



@admin.register(Submit_ZhuangBei)
class submit_zhuangbei_Admin(admin.ModelAdmin):
    list_display = ("name","leixing",'attrs_str',"pass_audit_str")
    search_fields = ("name",)
    list_filter = ('is_save',)


@admin.register(renwuattrs)
class renwuattrs_Admin(admin.ModelAdmin):
    list_display = ("renwu","liliang",'minjie',"ganzhi","zhili")



# django2\apps\business\admin.py
#
# from django.contrib import admin
# from django.contrib.admin import AdminSite
# from django.http import HttpResponse
# from django.urls import path
#
# # Register your models here.
#
# class DummyModel(models.Model):
#     class Meta:
#         verbose_name = "自定义路由"
#         verbose_name_plural = '自定义路由'
#         app_label = 'my_example'
#
#
# def my_custom_view(request):
#     return HttpResponse('自定义路由，写自己的内容')
#
#
# class DummyModelAdmin(admin.ModelAdmin):
#     model = DummyModel
#
#     def get_urls(self):
#         print(11111)
#         return [
#             path('', my_custom_view, name="my_custom_view"),
#         ]
#
#
#
# admin.site.register(DummyModel, DummyModelAdmin)



